<%@ page language="java" contentType="text/html; charset=utf-8" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="weaver.common.DateUtil" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="weaver.hrm.HrmUserVarify" %>
<%@ page import="weaver.hrm.User" %>
<%@ page import="weaver.interfaces.cese.duss.ceseutil.WorkflowCreateHandler" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Map" %>
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page"/>
<jsp:useBean id="rs1" class="weaver.conn.RecordSet" scope="page"/>
<jsp:useBean id="bb" class="weaver.general.BaseBean"/>
<%
    String ids = Util.null2String( request.getParameter( "ids" ) );//项目名称
    bb.writeLog( "ids=" + ids );
    User user = HrmUserVarify.getUser( request, response );
    int userid = user.getUID();
    String[] str = ids.split( "," );
    String creatorId = "";
    String workflowId = "17021";
    String requestName = "";
    String IsNextFlow = "0";
    Map<String, String> requestMainMap = new HashMap<>();
    WorkflowCreateHandler createHandler = new WorkflowCreateHandler();
    JSONObject jsonData = new JSONObject();
    String sql = "select id,xmmc,xmbh,gysmc,gysmcrl,lxfs from uf_dmd where id in (" + ids + ")";
    bb.writeLog( sql );
    rs.executeQuery( sql );
    int count = 0;
    while (rs.next()) {
        String xmmc = Util.null2String( rs.getString( "xmmc" ) );//项目名称
        String xmbh = Util.null2String( rs.getString( "xmbh" ) );//项目编号
        String gysmc = Util.null2String( rs.getString( "gysmc" ) );//供应商名称
        String gysmcrl = Util.null2String( rs.getString( "gysmcrl" ) );//供应商名称人力
        String lxfs = Util.null2String( rs.getString( "lxfs" ) );//联系方式
        creatorId = userid+"";
        requestName = "投标邀请函-" + DateUtil.getCurrentDate()+"-"+gysmcrl;
        requestMainMap.put( "sqr", userid+"" );//申请人
        requestMainMap.put( "zblx", xmmc );//项目名称
        requestMainMap.put( "xmbh", xmbh );//项目编号
        requestMainMap.put( "yqzz", gysmc );//邀请组织
        requestMainMap.put( "yqzz1", gysmc );//邀请组织
        requestMainMap.put( "lxfs", lxfs );//联系方式
        requestMainMap.put( "gys", gysmcrl );//联系方式
        String requestid = createHandler.WorkflowCreateByRequestMap( creatorId, workflowId, requestName, IsNextFlow, requestMainMap );
        bb.writeLog(Util.getIntValue( requestid ));
        if(Util.getIntValue( requestid ) > 0){
            count++;
        }
    }
    if (str.length == count)
    { jsonData.put( "success", "success" );
    }
    else { jsonData.put( "failed", "failed" );
    }
    out.print( jsonData.toJSONString() );
    bb.writeLog( "createTodoWorkflow_Ajax=" + jsonData.toJSONString() );
%>


